﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;

namespace Himp.DataHub
{
    public class DeptOperRmService : DataHubAppService, IDeptOperRmService
    {
        /// <summary>
        /// 
        /// </summary>
        private IRepository<DeptConsultRm, Guid> _topicConfigRepository;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="projectConfigRepository"></param>
        public DeptOperRmService(IRepository<DeptConsultRm, Guid> topicConfigRepository)
        {
            _topicConfigRepository = topicConfigRepository;
        }

        /// <summary>
        /// 获取消息业务类别
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<PagedResultDto<DeptOperRmDto>> GetListAsync(DeptOperRmInput input)
        {
            var iQuery = await _topicConfigRepository.GetQueryableAsync();

            if (input.Pi == 0)
            {
                var itemsDto = ObjectMapper.Map<List<DeptConsultRm>, List<DeptOperRmDto>>(iQuery.ToList());

                return new PagedResultDto<DeptOperRmDto>(itemsDto.Count, itemsDto);
            }
            else
            {
                var totalCount = iQuery.Count();
                var items = iQuery.Page(input.Pi, input.Ps);
                var itemsDto = ObjectMapper.Map<List<DeptConsultRm>, List<DeptOperRmDto>>(items.ToList());

                return new PagedResultDto<DeptOperRmDto>(totalCount, itemsDto);
            }
        }
    }
}
